<?php

declare(strict_types=1);
/**
 * This file is part of Hyperf.
 *
 * @link     https://www.hyperf.io
 * @document https://hyperf.wiki
 * @contact  group@hyperf.io
 * @license  https://github.com/hyperf/hyperf/blob/master/LICENSE
 */

namespace App\Command;

use App\Model\Content;
use App\Service\LoginService;
use Hyperf\Command\Annotation\Command;
use Hyperf\Command\Command as HyperfCommand;
use Hyperf\ModelCache\CacheableInterface;
use Psr\Container\ContainerInterface;

#[Command]
class test extends HyperfCommand
{
    protected $service;

    public function __construct(protected ContainerInterface $container)
    {
        parent::__construct('test:modelcache');
        $this->service = $this->container->get(LoginService::class);
    }

    public function configure()
    {
        parent::configure();
        $this->setDescription('测试');
    }

    public function handle()
    {
        //        var_dump(!Content::getModel() instanceof CacheableInterface);

        //       $model = Content::findFromCache(26);
        //       var_dump($model->toArray());
        //
        //       $model->title = '测试1234';
        //       $model->save();
        //       sleep(10);
        //
        //       $newModel = Content::findFromCache(26);
        //       var_dump($newModel->toArray());
    }
}
